package rcos.rpibuckhunter.archersfriend;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Spinner;

public class ScoreKeeper extends Activity {
	private static int count = 0;
	private Spinner first_arrow;
	private Spinner second_arrow;
	private Spinner third_arrow;
	//private static String[][] Score = new String[2][3];
	private String[] Score = new String[3];

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_score_keeper);
		count++;
		first_arrow = (Spinner) findViewById(R.id.spinner1);
		second_arrow = (Spinner) findViewById(R.id.spinner2);
		third_arrow = (Spinner)findViewById(R.id.spinner3);
		
		ArrayAdapter<CharSequence> adapter1 = ArrayAdapter.createFromResource(this, 
				R.array.first_arrow, android.R.layout.simple_selectable_list_item);
		ArrayAdapter<CharSequence> adapter2 = ArrayAdapter.createFromResource(this, 
				R.array.second_arrow, android.R.layout.simple_selectable_list_item);
		ArrayAdapter<CharSequence> adapter3 = ArrayAdapter.createFromResource(this, 
				R.array.third_arrow, android.R.layout.simple_selectable_list_item);
		
		adapter1.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
		adapter2.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
		adapter3.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
		
		first_arrow.setAdapter(adapter1);
		second_arrow.setAdapter(adapter2);
		third_arrow.setAdapter(adapter3);
	}
	
	public void onClick (View view) {
		String firstScore = first_arrow.getSelectedItem().toString();
		String secondScore = second_arrow.getSelectedItem().toString();
		String thirdScore = third_arrow.getSelectedItem().toString();
		
		/*Score[count-1][0] = firstScore;
		Score[count-1][1] = secondScore;
		Score[count-1][2] = thirdScore;*/
		
		Score[0]=firstScore;
		Score[1]=secondScore;
		Score[2]=thirdScore;
		
		if (count < 1) {
			finishActivity(0);
			startActivity(new Intent(ScoreKeeper.this, RoundTimer.class));
		}
		else {
			finishActivity(0);
			Intent i = new Intent(this, ScoreReport.class);
			Bundle b = new Bundle();
			b.putStringArray("score_array", Score);
			i.putExtras(b);
			startActivity(i);
		}
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.activity_score_keeper, menu);
		return true;
	}

}
